import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/components/special_operation/related_ticket_selection/related_ticket_selection_controller.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/application/execute_entity.dart';

/// 关联的其他特殊作业及安全作业票编号选择
class RelatedTicketSelectionPage extends StatelessWidget {
  RelatedTicketSelectionPage({super.key});

  final controller = Get.put(RelatedTicketSelectionController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        titleText: '其他作业选择',
      ),
      body: GetBuilder(
          init: controller,
          builder: (_) {
            return Container(
              padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w),
              alignment: Alignment.topCenter,
              color: const Color(0xffF5F5F6),
              child: CustomEasyRefreshList<ExecuteTicketReceiptList>(
                isShowSearch: true,
                dataLoad: controller.getDate,
                itemBuilder: (ExecuteTicketReceiptList item, int index) {
                  return Container(
                      padding: EdgeInsets.symmetric(
                          horizontal: 12.w, vertical: 16.w),
                      decoration: item.getIsChecked()
                          ? BoxDecoration(
                              borderRadius: BorderRadius.circular(8.w),
                              gradient: const LinearGradient(
                                  //渐变位置
                                  begin: Alignment.centerLeft,
                                  end: Alignment.centerRight,
                                  //渐变颜色[始点颜色, 结束颜色]
                                  colors: [
                                    Color(0xff3B62FF),
                                    Color(0xff9FB2FF)
                                  ]))
                          : BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(8.w)),
                      child: Row(
                        children: [
                          item.getIsChecked()
                              ? SvgPicture.asset(
                                  AppImages.icon_job_application_white,
                                  width: 28.w,
                                  height: 28.w,
                                )
                              : SvgPicture.asset(
                                  AppImages.icon_job_application_blue,
                                  width: 28.w,
                                  height: 28.w,
                                ),
                          AppGaps.hGap12,
                          Text(
                            item.getShowName(),
                            style: TextStyle(
                                color: item.getIsChecked()
                                    ? const Color(0xffffffff)
                                    : const Color(0xff262F38),
                                height: 1.2,
                                fontWeight: FontWeight.w400,
                                fontSize: 16.sp),
                          ),
                        ],
                      )).clickOnce(() {
                    controller.onTap(item);
                  });
                },
              ),
            );
          }),
      bottomSheet: Container(
        height: 50.w,
        width: double.infinity,
        color: Colors.white,
        padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 5.w),
        child: ElevatedButton(
          style: ElevatedButton.styleFrom(
            backgroundColor: AppColors.blue_button,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(22.r),
            ),
          ),
          onPressed: controller.complete,
          child: Text(
            '完成',
            style: TextStyle(
              fontSize: 16.sp,
              color: Colors.white,
            ),
          ),
        ),
      ),
    );
  }
}
